package com.bstech.Utils;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class Alarms {
	
	//System.currentTimeMillis()
	public static void Notify(Context context, long when, int notifyId, String tickerText, String title, String text, int iconResId, Intent intent)
	{

		Notification notification = new Notification(iconResId, tickerText,when);
		notification.defaults |= Notification.DEFAULT_SOUND;
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		
		PendingIntent contentIntent = null;
		if(intent != null)
		{
			try {
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
				contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);	
			} catch (Exception e) {
				e.printStackTrace();
				Log.w("loglog", "Common.Notify errore: " + e.toString());
			}
			
		}
		
		notification.setLatestEventInfo(context, title,text, contentIntent);

		String ns = Context.NOTIFICATION_SERVICE;
		NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(ns);
		mNotificationManager.notify(notifyId, notification);
	}
}
